//+------------------------------------------------------------------------------------------------------------------+
#property description                                                                         "[!!!-MT4 X-XARDg-PIP$]"
#define Version                                                                                         "[XARDg-PIP$]"
//+------------------------------------------------------------------------------------------------------------------+
#property link        "https://forex-station.com/viewtopic.php?p=1295409935#p1295409935"
#property description "THIS IS A FREE INDICATOR"
#property description "                                                      "
#property description "Welcome to the World of Forex"
#property description "Let light shine out of darkness and illuminate your world"
#property description "and with this freedom leave behind your cave of denial"
#property indicator_chart_window
     extern int posX=0,posY=-27,Corner=3,Window=0; 
   extern color DnColor=clrSalmon,UpColor=clrDodgerBlue; int x=NULL,pipsize; string SymPair="";
//+------------------------------------------------------------------------------------------------------------------+        
   int init(){string short_name; short_name="PIP$";IndicatorShortName(short_name);
   if(SymPair=="") SymPair=Symbol();
        if(StringFind  (Symbol(),"JPY",0) != -1)   pipsize=10;
   else if(StringSubstr(Symbol(),0,6)=="BTCUSD")   pipsize=100;
   else if(StringSubstr(Symbol(),0,6)=="ASX200")   pipsize=10;
   else if(StringSubstr(Symbol(),0,4)=="HK50")     pipsize=100;
   else if(StringSubstr(Symbol(),0,5)=="JP225")    pipsize=100;
   else if(StringSubstr(Symbol(),0,7)=="FTSE100")  pipsize=100;
   else if(StringSubstr(Symbol(),0,6)=="USDMXN")   pipsize=100;
   else if(StringSubstr(Symbol(),0,6)=="XAGUSD")   pipsize=10;
   else if(StringSubstr(Symbol(),0,6)=="XAUUSD")   pipsize=10;
   else if(StringSubstr(Symbol(),0,4)=="WS30")     pipsize=100;
   else if(StringSubstr(Symbol(),0,5)=="DAX30")    pipsize=100;
   else if(StringSubstr(Symbol(),0,6)=="ASX200")   pipsize=100; else pipsize=10;
   return(0);}
//+------------------------------------------------------------------------------------------------------------------+   
   int deinit(){int idx; if(x != NULL){for(idx=0;idx<x;idx++){ObjectDelete("PL"+idx);}
   ObjectDelete("ZTotal");} deleteObjects(); return(0);} 
//+------------------------------------------------------------------------------------------------------------------+
   int start(){int i,limit,counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars;   
   int j; string text; double PL,total; text=""; j=0; total=0;    
   for(i=OrdersTotal()-1;i>=0;i--){if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
   if(OrderType()==OP_BUY){
   PL=(OrderClosePrice()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT)/pipsize; total=total+PL;} else 
   if(OrderType()==OP_SELL){
   PL=(OrderOpenPrice()-OrderClosePrice())/MarketInfo(OrderSymbol(),MODE_POINT)/pipsize; total=total+PL;} }}  
   ObjectDelete("ZTotal");  
   if(total<0) DisplayText("ZTotal",    DoubleToStr(total,0),64,DnColor,10,15,"Arial Black");
   if(total>0) DisplayText("ZTotal","+"+DoubleToStr(total,0),64,UpColor,10,15,"Arial Black");  return(0);}
//+------------------------------------------------------------------------------------------------------------------+
   void DisplayText(string objname,string text,int fontsize,color clr,double X,double Y,string font){
              ObjectDelete(objname);
              ObjectCreate(objname,OBJ_LABEL,Window,0,0);
             ObjectSetText(objname,text,fontsize,font,clr);
                 ObjectSet(objname,OBJPROP_CORNER,Corner);
                 ObjectSet(objname,OBJPROP_XDISTANCE,X+posX);
                 ObjectSet(objname,OBJPROP_YDISTANCE,Y+posY);}
//+------------------------------------------------------------------------------------------------------------------+
   void deleteObjects(){ObjectDelete("ZTotal");}
//+------------------------------------------------------------------------------------------------------------------+